﻿namespace SugarTank.Mobile.Managers
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using CommonTypes.Domain;
    using Contracts;
    using Helpers;
    using Translators.Contract;
    using ViewModels;

    public class ContentManager : IContentManager
    {
        /// <summary>
        /// The injected item translator.
        /// </summary>
        private readonly ITranslator<Item, ItemViewModel> itemTranslator;

        /// <summary>
        /// Initializes a new instance of the <see cref="ContentManager"/> class.
        /// </summary>
        /// <param name="itemTranslator">The item translator.</param>
        public ContentManager(ITranslator<Item, ItemViewModel> itemTranslator)
        {
            this.itemTranslator = itemTranslator;
        }

        #region IContentManager Members

        /// <summary>
        /// Occurs when [get content items completed].
        /// </summary>
        public event EventHandler<EventArgs<IEnumerable<ItemViewModel>>> GetContentItemsCompleted;

        /// <summary>
        /// Gets the content items.
        /// </summary>
        public void GetContentItems()
        {
            var items = new ObservableCollection<Item>();

            items.Add(new Item
                          {
                              LineOne = "runtime one",
                              LineTwo = "Maecenas praesent accumsan bibendum",
                              LineThree =
                                  "Facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime two",
                              LineTwo = "Dictumst eleifend facilisi faucibus",
                              LineThree =
                                  "Suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime three",
                              LineTwo = "Habitant inceptos interdum lobortis",
                              LineThree =
                                  "Habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime four",
                              LineTwo = "Nascetur pharetra placerat pulvinar",
                              LineThree =
                                  "Ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime five",
                              LineTwo = "Maecenas praesent accumsan bibendum",
                              LineThree =
                                  "Maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime six",
                              LineTwo = "Dictumst eleifend facilisi faucibus",
                              LineThree =
                                  "Pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime seven",
                              LineTwo = "Habitant inceptos interdum lobortis",
                              LineThree =
                                  "Accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime eight",
                              LineTwo = "Nascetur pharetra placerat pulvinar",
                              LineThree =
                                  "Pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime nine",
                              LineTwo = "Maecenas praesent accumsan bibendum",
                              LineThree =
                                  "Facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime ten",
                              LineTwo = "Dictumst eleifend facilisi faucibus",
                              LineThree =
                                  "Suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime eleven",
                              LineTwo = "Habitant inceptos interdum lobortis",
                              LineThree =
                                  "Habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime twelve",
                              LineTwo = "Nascetur pharetra placerat pulvinar",
                              LineThree =
                                  "Ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime thirteen",
                              LineTwo = "Maecenas praesent accumsan bibendum",
                              LineThree =
                                  "Maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime fourteen",
                              LineTwo = "Dictumst eleifend facilisi faucibus",
                              LineThree =
                                  "Pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime fifteen",
                              LineTwo = "Habitant inceptos interdum lobortis",
                              LineThree =
                                  "Accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat"
                          });
            items.Add(new Item
                          {
                              LineOne = "runtime sixteen",
                              LineTwo = "Nascetur pharetra placerat pulvinar",
                              LineThree =
                                  "Pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum"
                          });

            GetContentItemsCompleted.FireEvent(this,
                                               () =>
                                               new EventArgs<IEnumerable<ItemViewModel>>(itemTranslator.Translate(items)));
        }

        #endregion
    }
}